home *** CD-ROM | disk | FTP | other *** search
/ TOS Silver 2000 / TOS Silver 2000.iso / programm / MM2_DEV / S / TEST / REAL.M < prev    next >
Encoding:
Text File  |  1991-04-18  |  4.7 KB  |  3 lines

  1. ⓪ MODULE Real;⓪ (*$E MOS *)⓪ IMPORT GEMDOSIO;⓪ FROM InOut      IMPORT  WriteLn,        WriteReal,      ReadReal,⓪8WriteString,    Read,           WriteLHex,⓪8WriteLNum,      WritePg,        WriteCard,⓪8WriteInt;⓪8⓪ FROM GrafBase   IMPORT  Pnt, Point;⓪ ⓪ FROM LineA      IMPORT  PutPixel;⓪ ⓪ FROM ErrBase    IMPORT  RaiseError,     ErrResp,        RtnCond;⓪ ⓪ FROM MOSGlobals IMPORT  DivByZero,      OutOfRange,     Overflow,⓪8StringOverflow;⓪ ⓪ FROM Convert    IMPORT  GetProc,        GetInfo,        ConvInt;⓪ ⓪ FROM MOSConfig  IMPORT  RadixChar;⓪ ⓪ FROM Strings    IMPORT  Length;⓪ ⓪ FROM Convert IMPORT ConvToReal, ConvFloat, ConvFix, ConvEng;⓪ FROM MathLib0 IMPORT sin, cos, tan, sqrt, fraction, rad, exp, pwrOfTen,⓪(entier,real,pwrOfTwo, ln, ld, log, power, logar;⓪ ⓪ TYPE⓪ ⓪"calcProc      =       PROCEDURE(LONGREAL) : LONGREAL;⓪"⓪ ⓪ VAR⓪ ⓪"c1, c2        :       LONGCARD;⓪"i1, i2        :       LONGINT;⓪"r, s          :       LONGREAL;⓪"c             :       CARDINAL;⓪"i             :       INTEGER;⓪"ch            :       CHAR;⓪"StartTime,⓪"EndTime       :       LONGCARD;⓪"prec          :       CARDINAL;⓪"mpos, epos    :       BOOLEAN;⓪"exponent      :       INTEGER;⓪"st            :       ARRAY[0..79] OF CHAR;⓪"stind         :       CARDINAL;⓪"info          :       GetInfo;⓪"valid         :       BOOLEAN;⓪"⓪ ⓪ PROCEDURE TestPlot(xR, yR : LONGREAL; yaxis : LONGINT; calc : calcProc);⓪ ⓪"VAR⓪"⓪$i, yk  : LONGINT;⓪$⓪"BEGIN⓪$WritePg;⓪$FOR i := 0 TO 639 DO⓪&PutPixel(Pnt(SHORT(i), 200), 1);⓪$END;⓪$IF (yaxis >= 0L) AND (yaxis <= 639L) THEN⓪&FOR i := 0 TO 399 DO⓪(PutPixel(Pnt(SHORT(yaxis), SHORT(i)), 1);⓪&END⓪$END;⓪$FOR i := 0 TO 639 DO⓪&yk := 200L + entier(yR * calc(real(i - yaxis) / xR));⓪&IF (yk >= 0L) AND (yk <= 639L) THEN⓪(PutPixel(Pnt(SHORT(i), SHORT(yk)), 1)⓪&END⓪$END;⓪$Read(ch);⓪"END TestPlot;⓪ ⓪ ⓪ PROCEDURE get(VAR Info : GetInfo);⓪"BEGIN⓪$IF stind >= Length(st) THEN⓪&Info.ch := 0C⓪$ELSE⓪&Info.ch := st[stind];⓪&INC(stind)⓪$END⓪"END get;⓪ ⓪ ⓪ BEGIN⓪"TestPlot(80.0, -80.0, 320L, sin);⓪"TestPlot(80.0, -80.0, 320L, cos);⓪"TestPlot(80.0, -80.0, 320L, tan);⓪"TestPlot(80.0, -80.0,   0L, sqrt);⓪"TestPlot(80.0, -80.0, 320L, fraction);⓪"TestPlot( 1.0, -20.0, 320L, rad);⓪"TestPlot(80.0, -80.0, 320L, exp);⓪"TestPlot(80.0, -80.0, 320L, pwrOfTen);⓪"TestPlot(80.0, -80.0, 320L, pwrOfTwo);⓪"TestPlot(80.0, -80.0,  -1L, ln);⓪"TestPlot(80.0, -80.0,  -1L, log);⓪"TestPlot(80.0, -80.0,  -1L, ld);⓪"WriteReal(power(3.0, 3.0), 24, 17);⓪"WriteLn;⓪"WriteReal(3.0 * 3.0 / 7.0, 24, 17);⓪"WriteLn;⓪"WriteReal(ln(3.0), 24, 17);⓪"WriteLn;⓪"WriteString('Overflow RMUL');⓪"WriteLn;⓪"r := 2.0;⓪"s := 1.0;⓪"FOR i := 1 TO 5000 DO⓪$s := s * r⓪"END;⓪"WriteReal(s, 24, 17);⓪"WriteLn;⓪"WriteString('Divide by 0 RDIV');⓪"WriteLn;⓪"s := 10.0;⓪"s := s / 0.0;⓪"WriteReal(s, 24, 17);⓪"WriteLn;⓪"WriteString('Overflow RDIV');⓪"WriteLn;⓪"s := 15.0E+307;⓪"s := s / 0.00001;⓪"WriteReal(s, 24, 17);⓪"WriteLn;⓪"WriteString('Overflow RADD');⓪"WriteLn;⓪"r := 15.0E+307;⓪"s := r + r;⓪"WriteReal(s, 24, 17);⓪"WriteLn;⓪"WriteString('Overflow RSUB');⓪"WriteLn;⓪"r := 15.0E+307;⓪"s := - 1.0 * r;⓪"s := r - s;⓪"WriteReal(s, 24, 17);⓪"WriteLn;⓪"WriteString('Out of range ln');⓪"WriteLn;⓪"s := ln(-1.0);⓪"WriteReal(s, 24, 17);⓪"WriteLn;⓪"WriteString('Out of range log');⓪"WriteLn;⓪"s := log(-1.0);⓪"WriteReal(s, 24, 17);⓪"WriteLn;⓪"WriteString('Out of range ld');⓪"WriteLn;⓪"s := ld(-1.0);⓪"WriteReal(s, 24, 17);⓪"WriteLn;⓪"WriteString('Overflow exp');⓪"WriteLn;⓪"s := exp(1000.0);⓪"WriteReal(s, 24, 17);⓪"WriteLn;⓪"WriteString('Overflow pwrOfTen');⓪"WriteLn;⓪"s := pwrOfTen(1000.0);⓪"WriteReal(s, 24, 17);⓪"WriteLn;⓪"WriteString('Overflow pwrOfTwo');⓪"WriteLn;⓪"s := pwrOfTwo(5000.0);⓪"WriteReal(s, 24, 17);⓪"WriteLn;⓪"WriteString('----------------------------');⓪"WriteLn;⓪"st := '-123.0412E-5';⓪"WriteString(st);⓪"stind := 0;⓪"r := ConvToReal(get, info, valid);⓪"IF ~valid THEN⓪$WriteString('not valid')⓪"ELSE⓪$ConvFloat(r, 22, 15, st);⓪$WriteString(st);⓪$WriteLn;⓪$ConvFix(r, 0, 15, st);⓪$WriteString(st)⓪"END;⓪"WriteLn;⓪"Read(ch)⓪ END Real.⓪ ə
  2. (* $FFF75CB2$FFF75CB2$FFF75CB2$FFF75CB2$FFF75CB2$FFF75CB2$FFF75CB2$FFF75CB2$FFF75CB2$FFF75CB2$FFF75CB2$FFF75CB2$FFF75CB2$FFF75CB2$FFF75CB2$00000AC3$FFF75CB2$FFF75CB2$FFF75CB2$FFF75CB2$FFF75CB2$FFF75CB2$FFF75CB2$FFF75CB2$FFF75CB2$FFF75CB2$FFF75CB2$FFF75CB2$FFF75CB2$FFF75CB2$FFF75CB2$FFF75CB2$FFF75CB2$FFF75CB2$FFF75CB2$FFF75CB2$FFF75CB2$FFF75CB2$FFF75CB2$FFF75CB2$FFF75CB2$FFF75CB2Ç$00000812T.......T.......T.......T.......T.......T.......T.......T.......T.......T.......$00000812$FFEDB240$00000812$FFEDB240$00000F53$00001000$00000F7E$00000791$000006C4$00000F6B$000002F6$0000002F$000002F6$0000002F$00000812$000009D0äÇâ*)
  3.